home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tsrhelp.zip / SCREEN.ASM < prev    next >
Assembly Source File  |  1992-08-22  |  18KB  |  596 lines

  1. ;---------------------------------------------------------------------------
  2. ; Program Name: Screen.Asm
  3. ;
  4. ; Author:       Steve Poulsen
  5. ;
  6. ;---------------------------------------------------------------------------
  7. Bios        Segment At 40h
  8.             Org 17h
  9. Shift       DB  ?
  10. Bios        EndS
  11. ;---------------------------------------------------------------------------
  12. Code        Segment
  13.             Assume CS:Code,DS:Code
  14.             Org 2Ch
  15. Env_Ptr     DW ?            
  16.             Org 80h
  17. Command     DB ?
  18.             Org 100h
  19. Start:      Jmp Initial
  20. Message     DB 'Screen Saver by Steve Poulsen$'
  21. OldInt_15   DD ?
  22. OldInt_08   DD ?
  23. Attribute   DB 00h
  24. Clear_Flag  DB 0
  25. Next_Flag   DB 0
  26. ShiftStatus DB 0
  27. StkSz       EQU 128
  28. Timer       DW  0
  29. Mess_Timer  DW  0
  30. Mess_Delay  DW  20
  31. Off_Delay   DW  600
  32. Delay       DW  1554h           ; 5 minutes
  33. VGA         DB  0
  34. ;---------------------------------------------------------------------------
  35. Include     Write.Inc
  36. Include     SaveScr.Inc
  37. Include     ClrScr.Inc
  38. Include     RestScr.Inc
  39. ;---------------------------------------------------------------------------
  40. ; Interrupt 15h Replacement
  41. ;---------------------------------------------------------------------------
  42. Int_15      Proc    Far
  43.             Assume CS:Code,DS:Nothing,ES:Nothing
  44.             
  45.             PushF
  46.             
  47.             Cmp AH,4Fh
  48.             JNE NoChange
  49.             
  50.             Mov CS:Timer,0
  51.             Cmp CS:Clear_Flag,0
  52.             JE NoRestore
  53.             
  54.             Cmp CS:VGA,0
  55.             JE NoVGARestore
  56.  
  57.             Push AX
  58.             Push BX
  59.             Mov AX,1200h
  60.             Mov BL,36h
  61.             Int 10h
  62.             Pop BX
  63.             Pop AX
  64.             Jmp Either
  65.             
  66. NoVGARestore:            
  67.             Push CX
  68.             Push DX
  69.             Push SI
  70.             Mov CX,0
  71.             Mov DX,184Fh
  72.             Mov SI,Offset CS:ScreenSave
  73.             Call RestScr
  74.             Pop SI
  75.             Pop DX
  76.             Pop CX
  77. Either:            
  78.             Dec CS:Clear_Flag
  79.             Push AX
  80.             Push ES
  81.             Mov AX,Offset Bios
  82.             Mov ES,AX
  83.             Mov AL,CS:ShiftStatus
  84.             Mov ES:Shift,AL
  85.             Pop ES
  86.             Pop AX
  87.             PopF
  88.             CLC
  89.             Jmp NoNull
  90.             
  91.             
  92. NoRestore:      
  93. NoChange:
  94.             PopF
  95.             PushF
  96.             Call DWord Ptr CS:[OldInt_15]
  97. NoNull:
  98.             Ret 2                   ; Flags intact
  99. Int_15      EndP                
  100. ;---------------------------------------------------------------------------
  101. ; Interrupt 08h Replacement
  102. ;---------------------------------------------------------------------------
  103. Int_08      Proc    Far
  104.             Assume CS:Code,DS:Nothing,ES:Nothing
  105.             Inc CS:Timer
  106.             Push AX
  107.             Mov AX,CS:Delay
  108.             Cmp CS:Timer,AX
  109.             JB NoCleara
  110.             Cmp CS:Clear_Flag,0
  111.             JNE Message_Flash
  112.             Jmp ClearScreen
  113.             
  114. NoCleara:
  115.             Jmp NoClear
  116.             
  117. ClearScreen:
  118.             Inc CS:Clear_Flag
  119.  
  120.             Push AX
  121.             Push ES
  122.             Mov AX,Offset Bios
  123.             Mov ES,AX
  124.             Mov AL,ES:Shift
  125.             Pop ES
  126.             Mov CS:ShiftStatus,AL
  127.             Push BX
  128.             Mov AX,1201h
  129.             Mov BL,36h
  130.             Int 10h
  131.             Cmp AL,12h
  132.             Pop BX
  133.             Pop AX
  134.             JNE NotVGA
  135.             Mov CS:VGA,01
  136.             Jmp Message_Flash
  137.             
  138. NotVGA:
  139.             Push CX
  140.             Push DX
  141.             Push SI
  142.             Mov CX,0
  143.             Mov DX,184Fh
  144.             Mov SI,Offset CS:ScreenSave
  145.             Call SaveScr
  146.             Mov SI,Offset CS:Attribute
  147.             Call ClrScr
  148.             Pop SI
  149.             Pop DX
  150.             Pop CX
  151.             
  152.             
  153. Message_Flash:
  154.             Cmp CS:VGA,01
  155.             JE NoClear
  156.             Push AX
  157.             Mov AX,CS:Mess_Delay
  158.             Cmp CS:Mess_Timer,AX
  159.             Pop AX
  160.             JG NoMessage 
  161.             Push SI
  162.             Push BX
  163.             Push CX
  164.             Mov SI,Offset CS:Message            
  165.             Mov BX,0A0Ah
  166.             Mov CL,0Fh
  167.             Call Write
  168.             Pop CX
  169.             Pop BX
  170.             Pop SI
  171.             Inc CS:Mess_Timer
  172.             Jmp NoClear
  173. NoMessage:
  174.             Inc CS:Mess_Timer
  175.             Push AX
  176.             Mov AX,CS:Off_Delay
  177.             Cmp CS:Mess_Timer,AX
  178.             Pop AX
  179.             JG Reset_Timer
  180.             Push SI
  181.             Push DX
  182.             Push CX
  183.             Mov CX,0
  184.             Mov DX,184Fh
  185.             Mov SI,Offset CS:Attribute
  186.             Call ClrScr
  187.             Pop CX
  188.             Pop DX
  189.             Pop SI
  190.             Jmp NoClear
  191. Reset_Timer:
  192.             Mov CS:Mess_Timer,0
  193.             
  194. NoClear:            
  195.             
  196.             Pop AX
  197.  
  198.             PushF
  199.             Call DWord Ptr CS:[OldInt_08]
  200.             IRet
  201. Int_08      EndP
  202. ;---------------------------------------------------------------------------
  203. Setup1 = $
  204. ;---------------------------------------------------------------------------
  205. ScreenSave  DW 2000 Dup (?)
  206. ;---------------------------------------------------------------------------
  207. Setup2 = $
  208. ;---------------------------------------------------------------------------
  209. Include Inst-Chk.Inc
  210. Include Check.Inc
  211. Include Remove.Inc
  212. Include RestInt.Inc
  213. Include Convert.Inc
  214. ;---------------------------------------------------------------------------
  215. Any_Flag        DB  0
  216. Activate_Flag   DB  0
  217. Remove_Flag     DB  0
  218. Help_Flag       DB  0
  219. Copyright_Mess  DB  'Screen Saver (c) 1992 By Steve Poulsen',13,10,10,'$'
  220. NoSupport_Mess  DB  'Interrupt 15h Mode 4Fh Not Supported by This Machine',13,10,'$'
  221. Illegal_Mess    DB  'Illegal Switch',13,10,'$'    
  222. Removed_Mess    DB  'Remove Successful',13,10,'$'
  223. Error_R_Mess    DB  'Can',44,'t Remove.  Please Reboot.',13,10,'$'
  224. Overlaid_Mess   DB  'Another TSR installed.  Shouldnt Remove',13,10,10,'$'
  225. Installed_Mess  DB  'Screen Saver Installed For $'
  226. Minutes_Mess    DB  ' Minute$'
  227. Install_Mess2   DB  '.',13,10,'$'
  228. NotInst_Mess    DB  'Not Installed',13,10,'$'
  229. AlreadyInst_Mess DB 'Already Installed',13,10,'$'
  230. BadTime_Mess    DB  'Illegal Time.',13,10,'$'
  231. Help_Mess       DB  13
  232.                 DB  'A screen blanker to prevent burn in on monitors.',13,10
  233.                 DB  'Performs a clear screen after a certain time of inactivity'
  234.                 DB  ' and returns the',13,10,'screen on a keypress.  Future updates plan'
  235.                 DB  ' to work for graphics mode, monitor',13,10,'comm port, and '
  236.                 DB  'monitor mouse.  Auto detect VGA hardware blanking.',13,10,10
  237.                 DB  'Commands:',13,10,10
  238.                 DB  '  /a        Installs to memory at a default of 5 minutes',13,10
  239.                 DB  '  /d        Removes from memory',13,10
  240.                 DB  '  /t<time>  Allows changing of time.  Time should be between'
  241.                 DB  ' 1 and 60 minutes.',13,10
  242.                 DB  '              Should be used with the /a option.',13,10
  243.                 DB  '  /h        This Menu',13,10,10
  244.                 DB  'Screen Saver is Shareware and payment is expected.',13,10
  245.                 DB  'Mail 5 dollars [or whatever]  to me at:',13,10
  246.                 DB  '    1227 Devonshire Lane',13,10
  247.                 DB  '    Rolla, MO  65401',13,10,'$' 
  248. NoComm_Mess     DB  13,10
  249.                 DB  '      ',0D6h,13 Dup (0C4h),0B7h,13,10
  250.                 DB  '      ',0BAh,'Steve Poulsen',0BAh,13,10
  251.                 DB  '      ',0D3h,13 Dup (0C4h),0BDh,13,10
  252.                 DB  '       1227 Devonshire Lane',13,10
  253.                 DB  '       Rolla, MO  65401',13,10,10
  254.                 DB  'Internet:  S105728@UMRVMA.UMR.EDU',13,10,10
  255.                 DB  '/a         Activate [default 5 minutes unless /t is used]'
  256.                 DB  13,10
  257.                 DB  '/d         Deactivate and remove from memory',13,10
  258.                 DB  '/t[1-60]   Set time until blank [in minutes]',13,10
  259.                 DB  '/h         Help [more extensive]',13,10,10
  260.                 DB  'If you like this please send 5 dollars. Use /h for address.'
  261.                 DB  13,10,'$'
  262. Switches        DB  'dhat'
  263. Switch_Addr     DW  Offset CS:Deactivate,Offset CS:Help,Offset CS:Activate
  264.                 DW  Offset CS:Time_Set
  265. Minutes         DW  5
  266. Minute_Convert  DB  '$$$$$$$$$$$$'
  267. ;---------------------------------------------------------------------------
  268. ;---------------------------------------------------------------------------
  269. ; Initial
  270. ;---------------------------------------------------------------------------
  271. ;---------------------------------------------------------------------------
  272. Initial     Proc    Near
  273.             Assume CS:Code,DS:Code,ES:Nothing
  274.             Push CS
  275.             Pop DS
  276.             
  277.             
  278.             Push ES
  279.             Mov AH,0C0h
  280.             Int 15h
  281.             Mov AX,ES:[BX+5]
  282.             Pop ES
  283.             Test AX,16h
  284.             JZ NoSupport
  285.             Jmp Support
  286.             
  287. Support:
  288.             Mov BL,2
  289.             Mov DI,Offset Command
  290.             Mov CL,[DI]
  291.             Cmp CL,0
  292.             JE NoCommands
  293.             Jmp Search
  294. Search:     
  295.             Mov AL,'/'
  296.             Scasb
  297.             Repne Scasb
  298.             JNE NoCommands
  299.             
  300.             Mov AL,[DI]
  301.             Or AL,20h
  302.             
  303.             Mov SI,Offset CS:Switches
  304. CheckNext:            
  305.             Cmp AL,[SI]
  306.             JE CorrectSwitch
  307. Continue:            
  308.             Inc SI
  309.             Cmp SI,Offset Switch_Addr
  310.             JE IllegalSwitch
  311.             Jmp CheckNext
  312. CorrectSwitch:
  313.             Sub SI,Offset Switches
  314.             SHL SI,1
  315.             Call [SI+Switch_Addr]
  316.             Jmp Search             
  317. IllegalSwitch:
  318.             Mov SI,Offset Illegal_Mess
  319.             Call WriteMess
  320.             Jmp Exit            
  321.             
  322. NoCommands:
  323.             Cmp CS:Any_Flag,0
  324.             JNE Exit_x
  325.             Call NoComm
  326. Exit_x:            
  327.             Jmp Exit
  328. NoSupport:
  329.             Mov SI,Offset CS:NoSupport_Mess
  330.             Call WriteMess
  331.             Jmp Exit
  332. ;---------------------------------------------------------------------------
  333. WriteMess   Proc    Near
  334.             Assume CS:Code,DS:Nothing,ES:Nothing
  335.             Push BX
  336.             Push DX
  337.             Push AX
  338.             Push DS
  339.             Push CS
  340.             Pop DS
  341.             
  342.             Mov CL,0    ;Leftmost position
  343.             Mov CH,0    ;Top of Screen
  344.             Mov DL,79   ;Rightmost position
  345.             Mov DH,24   ;Bottom of Screen
  346.             Mov BH,0Fh  ;White on Black
  347.             Mov AL,0
  348.             Mov AH,6    ;Scroll up
  349.             Int 10h
  350.             Mov BH,00h  ;Set Page zero of screen
  351.             Mov DL,00   ;Set cursor horiz. position
  352.             Mov DH,00   ;Set cursor vert.  position
  353.             Mov AH,02h  ;Set cursor position
  354.             Int 10h
  355.  
  356.             Mov DX,Offset Copyright_Mess
  357.             Mov AH,09h
  358.             Int 21h
  359.             
  360.             Mov DX,SI
  361.             Mov AH,09h
  362.             Int 21h
  363.             Pop DS
  364.             Pop AX
  365.             Pop DX
  366.             Pop BX
  367.             Ret
  368. WriteMess   EndP            
  369. ;---------------------------------------------------------------------------
  370. ;---------------------------------------------------------------------------
  371. Time_Set    Proc    Near
  372.             Assume CS:Code,DS:Nothing,ES:Nothing
  373.             Push AX
  374.             Push BX
  375.             Xor AX,AX
  376. Repeat_Time:            
  377.             Inc DI
  378.             Dec CX
  379.             Mov BL,[DI]
  380.             Cmp BL,20h
  381.             JE ValueDone
  382.             Cmp BL,0Dh
  383.             JE ValueDone
  384.             Sub BL,30h
  385.             Cmp BL,09h
  386.             JG IllegalTime
  387.             Push CX
  388.             Mov CX,10
  389.             Mul CL
  390.             Pop CX
  391.             Cmp AH,0
  392.             JNE IllegalTime
  393.             Mov BH,0
  394.             Add AX,BX
  395.             Jmp Repeat_Time
  396.             
  397. ValueDone:            
  398.             Mov CS:Minutes,AX
  399.             Push DX
  400.             Mov BX,444h
  401.             Mul BX
  402.             Cmp DX,0
  403.             Pop DX
  404.             JNE IllegalTime
  405.             Mov CS:Delay,AX
  406.             Jmp ValueSet
  407. IllegalTime:
  408.             Pop BX
  409.             Mov SI,Offset BadTime_Mess
  410.             Call WriteMess            
  411.             Mov CS:Minutes,0
  412.             Push BX
  413.             Inc CS:Any_Flag
  414.             Inc CS:Activate_Flag
  415.  
  416. ValueSet:            
  417.             Pop BX
  418.             Pop AX
  419.             Ret
  420. Time_Set    EndP        
  421. ;---------------------------------------------------------------------------
  422. ;---------------------------------------------------------------------------
  423. Activate    Proc    Near
  424.             Assume CS:Code,DS:Nothing,ES:Nothing
  425.             
  426.             Inc CS:Any_Flag
  427.             Cmp Activate_Flag,0
  428.             JNE NoInstall
  429.  
  430.             Call Install_Check
  431.             JC NotInstalled_A
  432.             Mov SI,Offset CS:AlreadyInst_Mess
  433.             Call WriteMess
  434.             Jmp NoInstall
  435.             
  436. NotInstalled_A:            
  437.             Inc CS:Activate_Flag
  438.             
  439. NoInstall:            
  440.             Ret
  441. Activate    EndP
  442. ;---------------------------------------------------------------------------
  443. ;---------------------------------------------------------------------------
  444. Deactivate  Proc    Near
  445.             Assume CS:Code,DS:Nothing,ES:Nothing
  446.             
  447.             Cmp CS:Remove_Flag,0
  448.             JNE Already_Remove
  449.             Call Install_Check
  450.             JC NotInstalled_R
  451.             Push AX
  452.             Mov AL,15h
  453.             Call Check
  454.             Pop AX
  455.             JC Overlaid
  456.             Push AX
  457.             Mov AL,08h
  458.             Call Check
  459.             Pop AX
  460.             JC Overlaid
  461.             Mov AL,15h
  462.             LDS DX,ES:[OldInt_15]     
  463.             Call RestInt
  464.             Mov AL,08h
  465.             LDS DX,ES:[OldInt_08]     
  466.             Call RestInt
  467.             Call Remove
  468.             JC Error_R
  469.             Mov SI,Offset CS:Removed_Mess
  470.             Jmp Message_R
  471.             
  472. Error_R:
  473.             Mov SI,Offset CS:Error_R_Mess
  474.             Jmp Message_R
  475.             
  476. Overlaid:
  477.             Mov SI,Offset CS:Overlaid_Mess
  478.             Jmp Message_R
  479.  
  480. NotInstalled_R: 
  481.             Mov SI,Offset CS:NotInst_Mess           
  482. Message_R:  
  483.             Call WriteMess          
  484.             Inc Byte Ptr CS:Remove_Flag
  485.             Inc Byte Ptr CS:Any_Flag
  486. Already_Remove:            
  487.             Ret
  488. Deactivate  EndP            
  489. ;---------------------------------------------------------------------------
  490. ;---------------------------------------------------------------------------
  491. Help        Proc    Near
  492.             Assume CS:Code,DS:Nothing,ES:Nothing
  493.             Cmp CS:Help_Flag,0
  494.             JNE Exit_H
  495.             Inc CS:Any_Flag
  496.             Inc CS:Help_Flag
  497.             Mov SI,Offset CS:Help_Mess
  498.             Call WriteMess
  499. Exit_H:                 
  500.             Ret
  501. Help        EndP            
  502. ;---------------------------------------------------------------------------
  503. ;---------------------------------------------------------------------------
  504. NoComm      Proc    Near
  505.             Assume CS:Code,DS:Nothing,ES:Nothing
  506.             Mov SI,Offset CS:NoComm_Mess
  507.             Call WriteMess
  508.             Ret
  509. NoComm      EndP            
  510. ;---------------------------------------------------------------------------
  511. Exit:       
  512.             Cmp CS:Minutes,0
  513.             JE ExitNicea
  514.             
  515.             Cmp CS:Activate_Flag,Byte Ptr 0
  516.             JNE NotExitNice
  517.             
  518. ExitNicea:
  519.             Jmp ExitNice
  520.             
  521. NotExitNice:
  522.             
  523.             Mov AX,3515h
  524.             Int 21h
  525.             Mov Word Ptr CS:[OldInt_15],BX
  526.             Mov Word Ptr CS:[OldInt_15+2],ES
  527.             Mov DX,Offset CS:Int_15
  528.             Mov AX,2515h
  529.             Int 21h
  530.             
  531.             Mov AX,3508h
  532.             Int 21h
  533.             Mov Word Ptr CS:[OldInt_08],BX
  534.             Mov Word Ptr CS:[OldInt_08+2],ES
  535.             Mov DX,Offset CS:Int_08
  536.             Mov AX,2508h
  537.             Int 21h
  538.  
  539.             Push AX
  540.             Push DI
  541.             Mov AX,CS:Minutes
  542.             Mov DI,Offset CS:Minute_Convert
  543.             Call Convert_Num
  544.             Pop DI
  545.             Pop AX
  546.             Mov SI,Offset CS:Installed_Mess
  547.             Call WriteMess
  548.             Mov DX,Offset CS:Minute_Convert
  549.             Mov AH,09h
  550.             Int 21h
  551.             Mov DX,Offset CS:Minutes_Mess
  552.             Mov AH,09h
  553.             Int 21h
  554.             Mov BX,CS:Minutes
  555.             Cmp BX,1
  556.             JE No_S
  557.             Mov DL,'s'
  558.             Mov AH,2
  559.             Int 21h
  560. No_S:            
  561.             Mov DX,Offset CS:Install_Mess2
  562.             Mov AH,09h
  563.             Int 21h
  564.             
  565.             Mov DX,Offset Setup2-Offset Code+StkSz
  566.             Mov AX,1201h
  567.             Mov BL,36h
  568.             Int 10h
  569.             Mov BH,AL
  570.             Mov AX,1200h
  571.             Int 10h
  572.             Cmp BH,12h
  573.             JNE DontChange
  574.             Mov DX,Offset Setup1-Offset Code+StkSz
  575. DontChange:            
  576.             Add DX,15
  577.             Mov CL,4
  578.             Shr DX,CL
  579.             Mov AX,3102h
  580.             Int 21h
  581.             
  582. ExitNice:
  583.             Mov AX,4C01h              
  584.             Int 21h
  585.  
  586.             
  587. Initial     EndP
  588. Code        EndS
  589.             End Start            
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.